#Copyright (C) Nial Peters 2012
#
#This file is part of AvoScan.
#
#AvoScan is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#AvoScan is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with AvoScan.  If not, see <http://www.gnu.org/licenses/>.

"""
The gui package provides a graphical user interface to the avoscan
package. This interface is used by the AvoScan script.
"""

from avoscan.gui import startup, main
import wx

def launch(allow_no_scanner=False):
    """
    Create the gui and start the program running.
    
    The allow_no_scanner option is designed to allow the GUI to be
    created even if there is no scanner detected. It is really only for
    testing purposes and there is no  guarantee that it will work!
    """
    f = startup.WaitingForConnectionDialog(None)
    scanner = f.connectToScanner(10000)
    wx.Yield()
    
    if scanner is None and not allow_no_scanner:
        return 
    
    if allow_no_scanner and scanner is None:
        main.MainFrame(None)
    else:
        #create the scanner zeroing window
        startup.ScannerZeroingFrame(scanner)
    
